package com.maigao.util;

import org.springframework.util.Assert;

import java.util.Arrays;
import java.util.OptionalInt;

/**
 * @program: speedticket
 * @description:
 * @author: yongza
 * @create: 2019-10-16 14:32
 **/
public class StatusUtil {
    public static boolean statusIn(int status, int... targetStatus) {
        if (targetStatus.length == 0) {
            Assert.notNull(null, "At Least One targetStatus!");
        }
        OptionalInt resultHolder = Arrays.stream(targetStatus).filter(t -> t == status).findFirst();
        if (resultHolder.isPresent()) {
            return true;
        }
        return false;
    }


    public static boolean statusNotIn(int status, int... targetStatus) {
        if (targetStatus.length == 0) {
            Assert.notNull(null, "At Least One targetStatus!");
        }
        OptionalInt resultHolder = Arrays.stream(targetStatus).filter(t -> t == status).findFirst();
        if (resultHolder.isPresent()) {
            return false;
        }
        return true;
    }
}
